/*
 * @file: postMessage用于跨窗口通信
 * @author: xiaoyu
 * @Date: 2021-07-12 01:07:14
 */
export default function () {
  function onMessage() {
    window.addEventListener('message', (data: any) => {
      console.log('接收的信息：', data)
    })
  }

  function sendMessage(dom: WindowProxy, target: string = '*', message: any) {
    dom.postMessage(target, message)
  }

  return {
    onMessage,
    sendMessage
  }
}
